#pragma once
#include<iostream>
using namespace std;
template<class T>



class Interval
{
private:
	T lower;
	T upper;

public:
	Interval() { lower=upper=0;}
	Interval(T mean, double procent)
	{
		lower=mean-mean*procent/100;
		upper=mean+mean*procent/100;
	}

	T mean() 
	{
		return (upper+lower)/2;
	}

	double relative_error()
	{
		return (upper-lower)/mean();
	}

	friend Interval<T> operator +(Interval<T> &lop, Interval<T> &rop)
	{
		Interval<T> m;
		m.upper= lop.upper + lop.lower;
		m.lower= rop.upper + rop.lower;
		return m;
	}

	void print_relative()
	{
		cout << "mean=" << mean() << ", relative_error=" << relative_error() << endl;

	}

	friend ostream & operator <<(ostream &out, const Interval<T> &ob)
	{
		out << "(" << ob.lower << "," << ob.upper << ")";
		return out;
	}
};

